source("../../lib/som-utils.R")
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
source("../../lib/maps-utils.R")
Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
mpr.set_base_path_analysis()
model <- mpr.load_model("som-319.rds.xz")
summary(model)
SOM of size 50x50 with a hexagonal topology and a bubble neighbourhood function.
The number of data layers is 1.
Distance measure(s) used: sumofsquares.
Training data included: 94881 objects.
Mean distance to the closest unit in the map: 0.008.
plot(model, type="changes")
df <- mpr.load_data("datos_mes.csv.xz")
df
summary(df)
id_estacion fecha fecha_cnt tmax
Length:94881 Length:94881 Min. : 1.000 Min. :-53.0
Class :character Class :character 1st Qu.: 4.000 1st Qu.:148.0
Mode :character Mode :character Median : 6.000 Median :198.0
Mean : 6.497 Mean :200.2
3rd Qu.: 9.000 3rd Qu.:255.0
Max. :12.000 Max. :403.0
tmin precip nevada prof_nieve
Min. :-121.00 Min. : 0.00 Min. :0.000000 Min. : 0.000
1st Qu.: 53.00 1st Qu.: 3.00 1st Qu.:0.000000 1st Qu.: 0.000
Median : 98.00 Median : 10.00 Median :0.000000 Median : 0.000
Mean : 98.86 Mean : 16.25 Mean :0.000295 Mean : 0.467
3rd Qu.: 148.00 3rd Qu.: 22.00 3rd Qu.:0.000000 3rd Qu.: 0.000
Max. : 254.00 Max. :422.00 Max. :6.000000 Max. :1834.000
longitud latitud altitud
Min. :27.82 Min. :-17.8889 Min. : 1.0
1st Qu.:38.28 1st Qu.: -5.6417 1st Qu.: 42.0
Median :40.82 Median : -3.4500 Median : 247.0
Mean :39.66 Mean : -3.4350 Mean : 418.5
3rd Qu.:42.08 3rd Qu.: 0.4914 3rd Qu.: 656.0
Max. :43.57 Max. : 4.2156 Max. :2535.0
world <- ne_countries(scale = "medium", returnclass = "sf")
spain <- subset(world, admin == "Spain")
plot(model, type="count", shape = "straight", palette.name = mpr.degrade.bleu)
Número de elementos en cada celda:
nb <- table(model$unit.classif)
print(nb)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
16 16 9 22 16 21 7 17 25 28 24 39 21 21 31 48
17 18 19 20 21 22 23 24 25 26 28 29 30 31 32 33
27 59 45 63 59 48 69 63 46 28 80 53 55 47 47 33
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
18 51 48 52 49 43 49 41 35 28 17 27 33 33 39 20
50 51 52 53 55 56 57 58 59 60 61 62 63 64 65 66
8 10 3 45 17 39 15 24 26 33 23 29 35 33 20 37
67 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
41 60 49 55 72 53 66 93 39 25 84 53 54 89 53 41
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
59 90 32 42 45 34 60 56 69 53 44 41 31 41 33 29
100 101 103 104 105 106 107 109 111 113 114 115 116 117 119 121
24 26 61 7 12 63 12 33 63 19 20 27 36 60 54 58
122 123 125 126 127 135 136 137 138 139 140 141 142 143 144 145
51 58 84 27 65 77 32 36 49 35 34 33 38 30 28 35
146 147 148 149 150 151 152 155 156 157 158 159 160 162 164 166
27 24 21 15 10 29 25 22 20 14 21 26 48 57 57 57
167 168 169 170 171 172 173 174 175 176 177 179 180 181 182 184
40 41 54 50 60 65 73 55 59 47 78 47 28 52 42 51
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
73 81 84 71 40 58 40 52 51 38 46 24 5 24 10 26
202 203 205 206 207 208 210 212 213 214 215 217 222 223 224 225
42 19 14 36 25 25 85 97 73 53 57 67 64 51 66 79
228 229 230 231 232 233 234 235 239 240 241 242 243 244 245 246
32 67 93 59 96 85 44 59 43 48 55 45 37 32 25 11
247 248 249 250 251 252 253 255 257 259 261 262 264 266 268 270
16 19 26 13 42 26 48 47 21 52 88 99 92 90 59 61
271 273 274 276 277 278 279 284 285 286 287 288 289 294 295 296
66 54 58 26 92 84 96 83 69 68 77 55 57 14 25 19
297 298 299 300 301 302 303 305 307 308 312 314 316 318 320 321
40 21 24 15 32 45 21 59 47 46 156 71 78 96 44 72
323 324 325 330 331 332 338 339 340 341 342 343 344 345 346 347
46 23 82 111 127 44 75 54 67 67 40 41 20 40 39 18
348 349 350 351 352 353 355 356 358 359 360 361 367 369 372 373
21 4 20 32 23 63 63 61 16 67 78 79 68 66 52 55
375 377 378 379 380 382 383 384 385 386 387 388 394 395 396 397
67 61 97 119 95 99 70 52 93 87 51 65 59 42 20 30
398 399 400 401 402 403 405 406 408 409 410 411 413 415 417 419
21 20 9 48 18 49 61 51 27 22 32 66 119 121 109 86
420 422 423 427 428 429 430 431 432 433 434 436 437 438 439 440
93 80 73 29 33 51 34 72 36 55 87 66 82 94 74 87
441 442 443 444 445 446 448 449 450 451 452 453 454 456 457 462
89 57 76 28 41 27 31 19 31 31 40 30 48 37 42 67
464 467 468 471 474 476 477 478 479 480 481 482 483 484 485 486
87 46 57 112 85 83 8 30 21 29 43 52 36 49 51 63
487 488 489 490 491 492 493 494 495 497 498 499 500 501 502 503
39 56 39 30 26 32 29 28 40 32 33 1 23 65 38 58
505 506 508 509 510 512 514 515 517 518 519 521 522 526 528 531
74 49 59 65 97 57 78 90 53 151 72 130 64 84 22 42
534 535 536 537 538 539 540 541 542 543 545 546 548 549 550 551
42 51 36 51 32 52 35 27 35 34 42 43 5 21 19 44
552 553 554 556 558 559 563 565 566 567 569 570 573 575 577 578
35 54 43 99 32 42 123 57 114 71 72 94 165 133 95 46
579 580 583 584 594 595 596 597 598 600 601 602 603 605 607 608
16 38 65 98 43 33 10 13 15 9 50 55 32 103 37 32
609 610 611 616 617 619 620 621 628 631 634 635 636 637 638 639
27 28 28 58 114 81 89 100 79 50 64 40 77 66 36 59
640 641 642 643 645 646 647 648 649 650 651 652 653 654 657 658
63 55 63 51 28 16 9 9 32 17 56 25 45 37 34 30
659 660 661 662 664 665 668 671 673 675 676 677 679 680 681 682
31 34 30 64 100 95 104 101 113 61 87 102 102 90 42 43
683 684 685 686 687 688 689 690 691 692 693 694 695 697 698 699
52 29 29 23 12 31 4 5 13 1 2 11 23 15 11 23
700 701 702 703 704 705 706 707 708 709 710 712 715 716 719 723
38 25 46 34 19 25 20 13 38 50 27 75 78 39 108 52
734 735 736 737 738 739 740 741 742 744 745 746 747 748 749 750
52 55 78 49 38 60 45 36 32 8 26 11 18 17 23 23
751 752 753 754 755 756 757 759 760 761 763 764 766 767 769 770
41 28 24 19 20 30 30 44 45 57 60 83 37 80 109 96
772 774 775 777 779 780 781 782 783 784 790 791 792 794 795 796
179 93 59 81 108 96 77 69 62 96 28 30 35 39 34 15
797 798 799 800 801 802 803 804 805 806 807 809 810 811 812 814
8 12 22 26 30 39 15 16 26 35 25 34 35 37 42 87
816 818 825 827 830 834 835 836 837 838 839 842 843 844 845 846
62 151 86 56 42 53 77 35 58 53 43 19 33 5 14 26
847 848 849 850 851 852 853 854 855 856 857 859 861 862 863 865
6 26 16 26 17 16 13 24 22 42 27 95 34 54 48 100
867 870 871 872 874 876 878 879 882 883 884 891 892 893 894 895
131 132 97 116 140 106 69 93 57 61 47 55 49 44 7 19
896 898 899 900 901 902 903 904 905 906 907 909 910 911 913 915
35 31 34 23 22 19 27 23 37 26 34 65 51 45 78 90
918 922 924 926 930 935 936 937 938 939 940 941 942 943 944 946
77 120 88 81 77 50 83 65 60 48 35 19 26 18 21 9
947 948 949 950 951 952 953 954 955 957 959 961 962 964 968 970
32 39 22 23 19 33 15 14 41 34 90 80 35 69 287 105
971 973 975 978 979 980 981 982 983 984 985 986 987 988 989 990
101 65 86 43 110 84 71 118 53 65 102 12 18 22 22 19
991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006
31 33 32 13 17 11 8 18 33 34 17 6 25 29 22 11
1007 1009 1011 1012 1013 1014 1016 1019 1020 1022 1024 1026 1027 1028 1029 1031
24 103 90 47 37 88 152 92 72 118 38 45 106 49 39 11
1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1044 1045 1046 1047 1048
6 20 15 11 77 75 38 57 54 15 39 13 32 14 30 18
1049 1050 1051 1052 1053 1056 1057 1058 1060 1061 1063 1064 1065 1068 1074 1076
34 29 47 31 7 23 37 33 114 56 60 61 74 71 104 46
1077 1079 1080 1081 1082 1083 1084 1085 1086 1094 1095 1096 1097 1098 1099 1100
61 28 22 20 20 20 27 35 59 37 13 22 32 20 41 27
1101 1102 1103 1104 1105 1106 1107 1108 1110 1111 1115 1116 1117 1118 1120 1121
18 46 44 28 43 41 56 62 71 138 106 52 78 136 275 76
1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1137 1139 1140 1142 1146
42 61 72 58 36 25 26 65 88 43 65 75 51 37 56 21
1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1163 1164 1170
22 20 28 33 36 36 32 26 32 45 34 21 34 45 35 45
1171 1172 1174 1175 1176 1178 1179 1180 1181 1182 1183 1184 1185 1187 1189 1190
99 97 98 120 68 74 70 60 97 24 53 38 52 76 81 29
1191 1192 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207
24 35 50 43 17 38 24 51 21 44 45 39 25 40 43 34
1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1220 1221 1224 1226 1227
40 35 116 11 36 29 30 155 107 49 25 80 71 141 42 43
1228 1229 1230 1231 1232 1235 1236 1238 1245 1246 1247 1248 1249 1250 1251 1252
39 33 45 28 25 22 65 129 31 35 20 59 21 38 31 36
1253 1254 1255 1256 1257 1258 1259 1261 1262 1263 1264 1265 1267 1268 1269 1271
24 39 37 30 51 34 23 13 33 25 28 19 42 31 44 124
1273 1275 1276 1277 1278 1281 1283 1284 1285 1286 1290 1291 1293 1294 1295 1296
147 94 54 49 78 40 25 48 85 68 50 42 17 38 40 48
1297 1298 1299 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313
21 64 26 49 26 33 20 57 19 53 85 10 38 26 43 19
1315 1316 1317 1318 1319 1320 1321 1324 1325 1326 1327 1329 1332 1333 1334 1337
54 49 51 29 33 63 116 108 89 81 101 467 55 95 66 48
1338 1339 1340 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355
53 30 41 30 33 30 25 43 26 35 21 58 38 16 32 40
1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1371 1372 1373
59 95 27 37 44 23 97 100 99 23 39 14 36 91 85 51
1375 1379 1380 1382 1383 1386 1387 1389 1390 1392 1394 1396 1397 1399 1401 1402
148 77 53 59 59 93 82 35 40 40 47 45 44 47 47 32
1403 1404 1405 1406 1407 1408 1409 1410 1411 1413 1414 1415 1416 1417 1419 1420
35 53 54 18 14 38 34 90 99 45 52 12 29 25 77 38
1422 1423 1426 1427 1428 1429 1431 1432 1434 1435 1438 1439 1441 1442 1443 1445
48 52 52 51 119 59 72 78 88 74 39 22 21 42 67 43
1447 1448 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1462 1463 1464
50 39 287 54 18 36 51 15 16 21 45 69 95 62 38 19
1465 1466 1467 1468 1470 1471 1472 1473 1475 1476 1477 1478 1481 1482 1485 1487
25 21 180 70 38 47 27 32 56 47 46 52 49 52 48 31
1488 1489 1491 1492 1493 1494 1495 1500 1501 1502 1503 1504 1505 1506 1507 1508
41 27 42 45 24 51 85 88 17 29 30 22 28 27 67 77
1509 1510 1511 1512 1513 1514 1515 1518 1519 1520 1521 1522 1523 1525 1526 1527
22 41 29 17 40 19 23 137 109 37 36 29 58 90 96 47
1529 1531 1533 1534 1536 1537 1538 1539 1546 1547 1548 1551 1552 1553 1554 1555
150 153 37 40 45 40 40 41 58 115 435 37 30 19 15 68
1556 1557 1558 1559 1560 1561 1562 1563 1565 1566 1567 1569 1570 1571 1572 1573
57 68 18 38 22 44 31 75 33 54 40 32 59 92 71 80
1575 1579 1580 1583 1584 1585 1587 1588 1591 1592 1593 1595 1597 1600 1601 1602
114 63 72 69 52 39 42 48 31 16 7 408 58 272 25 19
1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1617 1618 1619
70 46 32 23 31 40 30 51 47 49 52 59 38 65 33 17
1626 1627 1629 1631 1632 1636 1637 1639 1640 1641 1642 1643 1644 1646 1648 1650
46 52 117 149 69 30 38 28 33 26 13 46 44 77 293 110
1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666
29 31 43 32 15 30 18 19 36 39 49 55 32 57 55 54
1667 1668 1669 1670 1671 1672 1673 1674 1675 1677 1678 1680 1684 1685 1689 1690
15 34 14 30 82 70 21 77 95 55 68 154 128 48 68 27
1692 1694 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709
22 35 58 52 52 65 59 39 44 18 23 24 27 36 71 73
1710 1711 1712 1713 1714 1715 1717 1718 1719 1720 1721 1722 1723 1724 1726 1727
48 28 45 58 5 53 29 17 52 41 37 22 90 30 83 25
1728 1731 1732 1734 1735 1737 1738 1740 1741 1742 1743 1744 1745 1746 1748 1750
55 66 73 73 32 356 76 30 32 24 28 27 63 25 65 54
1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766
38 46 32 37 25 24 50 46 47 49 51 69 9 52 59 48
1767 1768 1769 1770 1771 1772 1773 1775 1776 1778 1780 1781 1782 1783 1785 1786
128 14 64 45 26 44 43 73 58 52 105 30 31 28 47 80
1790 1791 1796 1797 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810
76 37 15 75 55 35 24 28 25 27 56 28 40 40 30 42
1811 1812 1813 1814 1815 1816 1817 1818 1820 1821 1822 1824 1826 1827 1828 1830
40 50 39 31 21 57 30 125 33 62 98 76 58 36 38 3
1831 1832 1833 1836 1837 1839 1842 1843 1844 1847 1848 1849 1850 1851 1852 1853
16 42 54 66 41 392 55 59 37 13 50 34 42 23 28 35
1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869
35 35 45 28 37 28 31 23 33 8 18 11 99 42 21 39
1870 1871 1872 1874 1876 1877 1878 1880 1882 1885 1887 1888 1891 1892 1893 1894
24 82 65 80 65 40 33 187 59 43 68 49 188 68 36 51
1895 1896 1898 1899 1900 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912
45 43 42 46 32 43 39 49 28 26 30 30 49 62 88 89
1913 1914 1915 1916 1917 1918 1919 1920 1921 1923 1925 1926 1927 1928 1931 1933
47 45 94 59 17 37 101 64 61 63 84 52 22 25 144 48
1934 1935 1939 1944 1945 1946 1948 1949 1950 1951 1953 1954 1955 1956 1957 1958
43 53 64 40 27 24 8 29 28 29 27 26 9 49 37 62
1959 1960 1961 1962 1963 1964 1968 1969 1972 1973 1975 1976 1977 1979 1980 1983
56 20 44 22 39 45 78 183 93 151 45 51 22 20 57 32
1984 1985 1986 1987 1989 1991 1992 1993 1995 1996 1997 1999 2000 2002 2003 2004
31 50 25 60 57 49 51 50 25 36 47 23 21 21 28 26
2005 2006 2007 2008 2009 2010 2011 2012 2015 2016 2020 2021 2024 2025 2026 2027
29 22 31 29 28 48 74 66 65 140 125 126 120 79 31 42
2028 2029 2030 2031 2033 2034 2036 2037 2039 2041 2043 2046 2047 2049 2050 2051
20 29 21 51 40 28 105 42 55 38 57 54 32 16 11 26
2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2064 2065 2068 2073 2077 2078
30 16 38 12 30 32 41 46 47 27 71 83 140 45 17 25
2079 2080 2081 2084 2085 2087 2088 2090 2092 2093 2095 2098 2099 2100 2101 2102
73 55 51 35 31 45 61 68 51 54 77 30 14 10 41 31
2103 2104 2105 2106 2107 2108 2109 2110 2112 2113 2116 2119 2120 2121 2123 2125
35 15 25 35 59 21 15 99 46 64 76 127 97 86 75 48
2126 2127 2128 2129 2131 2132 2134 2137 2138 2140 2142 2143 2145 2146 2148 2150
24 108 54 44 41 23 41 63 62 75 48 67 37 44 33 8
2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2162 2163 2164 2165 2166 2168
42 29 34 26 26 32 10 7 54 62 64 32 55 53 81 153
2173 2175 2177 2178 2181 2183 2185 2186 2188 2189 2191 2193 2194 2196 2197 2200
248 66 71 40 45 44 49 50 48 45 78 71 28 48 28 18
2201 2202 2203 2204 2205 2206 2207 2208 2209 2211 2213 2216 2217 2219 2221 2224
60 34 18 26 37 37 57 56 42 42 40 49 70 190 165 49
2225 2226 2227 2229 2230 2232 2234 2236 2238 2239 2241 2243 2244 2246 2247 2249
46 122 90 84 55 43 59 57 49 56 81 31 42 35 150 51
2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2261 2262 2263 2265 2266 2267
31 40 19 29 40 18 38 21 28 42 16 38 53 66 39 61
2271 2274 2276 2279 2281 2282 2284 2286 2287 2289 2290 2294 2295 2296 2299 2300
98 297 125 79 46 46 54 24 57 81 48 55 47 47 43 56
2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2318 2319
36 26 15 39 32 43 19 47 61 14 28 26 43 28 102 73
2320 2321 2322 2325 2327 2328 2330 2333 2335 2336 2337 2339 2340 2341 2342 2345
81 88 119 292 55 72 54 72 55 21 44 71 55 45 206 200
2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2360 2361 2362 2363
40 27 27 39 18 14 30 24 26 19 22 22 17 36 27 40
2364 2365 2366 2367 2368 2369 2370 2371 2374 2377 2378 2380 2382 2383 2385 2386
42 75 61 68 49 55 46 43 286 69 46 75 85 58 35 14
2387 2388 2390 2391 2392 2394 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407
46 45 39 66 68 128 44 61 54 19 28 24 17 40 37 35
2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2419 2420 2421 2422 2425 2426
25 31 33 23 25 30 29 40 45 63 61 74 90 131 93 102
2429 2430 2432 2434 2435 2436 2437 2438 2440 2442 2444 2446 2448 2449 2450 2451
32 22 54 31 57 23 24 84 37 229 72 63 56 46 79 39
2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467
25 37 23 25 21 32 30 28 33 44 65 48 72 74 96 58
2468 2469 2470 2471 2472 2473 2474 2476 2478 2479 2480 2482 2484 2485 2487 2489
122 79 60 64 72 92 214 228 171 70 70 238 158 41 340 226
2491 2494 2496 2497 2499 2500
200 391 308 183 435 82
Comprobación de nodos vacíos:
dim_model <- 50*50;
len_nb = length(nb);
empty_nodes <- dim_model != len_nb;
if (empty_nodes) {
print(paste("[Warning] Existen nodos vacíos: ", len_nb, "/", dim_model))
}
[1] "[Warning] Existen nodos vacíos: 1798 / 2500"
plot(model, type="dist.neighbours", shape = "straight")
model_colnames = c("precip", "longitud", "latitud", "altitud")
model_ncol = length(model_colnames)
plot(model, shape = "straight")
par(mfrow=c(3,4))
for (j in 1:model_ncol) {
plot(model, type="property", property=getCodes(model,1)[,j],
palette.name=mpr.coolBlueHotRed,
main=model_colnames[j],
cex=0.5, shape = "straight")
}
if (!empty_nodes) {
cor <- apply(getCodes(model,1), 2, mpr.weighted.correlation, w=nb, som=model)
print(cor)
}
Representación de cada variable en un mapa de factores:
if (!empty_nodes) {
par(mfrow=c(1,1))
plot(cor[1,], cor[2,], xlim=c(-1,1), ylim=c(-1,1), type="n")
lines(c(-1,1),c(0,0))
lines(c(0,0),c(-1,1))
text(cor[1,], cor[2,], labels=model_colnames, cex=0.75)
symbols(0,0,circles=1,inches=F,add=T)
}
Importancia de cada variable - varianza ponderada por el tamaño de la celda:
if (!empty_nodes) {
sigma2 <- sqrt(apply(getCodes(model,1),2,function(x,effectif)
{m<-sum(effectif*(x-weighted.mean(x,effectif))^2)/(sum(effectif)-1)},
effectif=nb))
print(sort(sigma2,decreasing=T))
}
if (!empty_nodes) {
hac <- mpr.hac(model, nb)
}
if (!empty_nodes) {
plot(hac, hang=-1, labels=F)
rect.hclust(hac, k=3)
}
A qué clúster pertenece cada nodo del mapa de kohonen:
if (!empty_nodes) {
groups <- cutree(hac, k=3)
plot(model, type="mapping",
bgcol=c("steelblue1","sienna1","yellowgreen","red","blue","yellow","purple","green","white","#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')[groups],
shape = "straight", labels = "")
add.cluster.boundaries(model, clustering=groups)
}
if (!empty_nodes) {
# Asignamos a cada registro su clúster
df$cluster <- groups[model$unit.classif]
}
Nuevos dataframes por cluster
if (!empty_nodes) {
# Creo nuevos dataframes, uno por cada clúster.
df.cluster01 <- subset(df, cluster==1)
df.cluster02 <- subset(df, cluster==2)
df.cluster03 <- subset(df, cluster==3)
# Extraigo del dataframe las features.
df.cluster01 <- select(df.cluster01, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster02 <- select(df.cluster02, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster03 <- select(df.cluster03, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
}
if (!empty_nodes) summary(df.cluster01)
if (!empty_nodes) summary(df.cluster02)
if (!empty_nodes) summary(df.cluster03)
if (!empty_nodes) {
df.clusters.dim <- c(dim(df.cluster01)[1], dim(df.cluster02)[1], dim(df.cluster03)[1])
barplot(df.clusters.dim,
names.arg = c("cluster01", "cluster02", "cluster03"),
col = "steelblue1")
}
if (!empty_nodes) mpr.hist(df.cluster01)
if (!empty_nodes) mpr.hist(df.cluster02)
if (!empty_nodes) mpr.hist(df.cluster03)
if (!empty_nodes) mpr.boxplot(df.cluster01)
if (!empty_nodes) mpr.boxplot(df.cluster02)
if (!empty_nodes) mpr.boxplot(df.cluster03)
# Agrupa por longitud y latitud para rellenar el mapa con menos datos.
if (!empty_nodes) {
df.cluster01.grouped <- mpr.group_by_geo(df.cluster01)
df.cluster02.grouped <- mpr.group_by_geo(df.cluster02)
df.cluster03.grouped <- mpr.group_by_geo(df.cluster03)
}
if (!empty_nodes) mpr.draw_map(spain, df.cluster01.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster02.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster03.grouped)
if (!empty_nodes) {
plot(hac, hang=-1, labels=F)
rect.hclust(hac, k=4)
}
A qué clúster pertenece cada nodo del mapa de kohonen:
if (!empty_nodes) {
groups <- cutree(hac, k=4)
plot(model, type="mapping",
bgcol=c("steelblue1","sienna1","yellowgreen","red","blue","yellow","purple","green","white","#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')[groups],
shape = "straight", labels = "")
add.cluster.boundaries(model, clustering=groups)
}
if (!empty_nodes) {
# Asignamos a cada registro su clúster
df$cluster <- groups[model$unit.classif]
}
Nuevos dataframes por cluster
if (!empty_nodes) {
# Creo nuevos dataframes, uno por cada clúster.
df.cluster01 <- subset(df, cluster==1)
df.cluster02 <- subset(df, cluster==2)
df.cluster03 <- subset(df, cluster==3)
df.cluster04 <- subset(df, cluster==4)
# Extraigo del dataframe las features.
df.cluster01 <- select(df.cluster01, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster02 <- select(df.cluster02, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster03 <- select(df.cluster03, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster04 <- select(df.cluster04, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
}
if (!empty_nodes) summary(df.cluster01)
if (!empty_nodes) summary(df.cluster02)
if (!empty_nodes) summary(df.cluster03)
if (!empty_nodes) summary(df.cluster04)
if (!empty_nodes) {
df.clusters.dim <- c(dim(df.cluster01)[1], dim(df.cluster02)[1], dim(df.cluster03)[1], dim(df.cluster04)[1])
barplot(df.clusters.dim,
names.arg = c("cluster01", "cluster02", "cluster03", "cluster04"),
col = "steelblue1")
}
if (!empty_nodes) mpr.hist(df.cluster01)
if (!empty_nodes) mpr.hist(df.cluster02)
if (!empty_nodes) mpr.hist(df.cluster03)
if (!empty_nodes) mpr.hist(df.cluster04)
if (!empty_nodes) mpr.boxplot(df.cluster01)
if (!empty_nodes) mpr.boxplot(df.cluster02)
if (!empty_nodes) mpr.boxplot(df.cluster03)
if (!empty_nodes) mpr.boxplot(df.cluster04)
# Agrupa por longitud y latitud para rellenar el mapa con menos datos.
if (!empty_nodes) {
df.cluster01.grouped <- mpr.group_by_geo(df.cluster01)
df.cluster02.grouped <- mpr.group_by_geo(df.cluster02)
df.cluster03.grouped <- mpr.group_by_geo(df.cluster03)
df.cluster04.grouped <- mpr.group_by_geo(df.cluster04)
}
if (!empty_nodes) mpr.draw_map(spain, df.cluster01.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster02.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster03.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster04.grouped)
if (!empty_nodes) {
plot(hac, hang=-1, labels=F)
rect.hclust(hac, k=5)
}
A qué clúster pertenece cada nodo del mapa de kohonen:
if (!empty_nodes) {
groups <- cutree(hac, k=5)
plot(model, type="mapping",
bgcol=c("steelblue1","sienna1","yellowgreen","red","blue","yellow","purple","green","white","#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')[groups],
shape = "straight", labels = "")
add.cluster.boundaries(model, clustering=groups)
}
if (!empty_nodes) {
# Asignamos a cada registro su clúster
df$cluster <- groups[model$unit.classif]
}
Nuevos dataframes por cluster
if (!empty_nodes) {
# Creo nuevos dataframes, uno por cada clúster.
df.cluster01 <- subset(df, cluster==1)
df.cluster02 <- subset(df, cluster==2)
df.cluster03 <- subset(df, cluster==3)
df.cluster04 <- subset(df, cluster==4)
df.cluster05 <- subset(df, cluster==5)
# Extraigo del dataframe las features.
df.cluster01 <- select(df.cluster01, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster02 <- select(df.cluster02, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster03 <- select(df.cluster03, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster04 <- select(df.cluster04, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster05 <- select(df.cluster05, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
}
if (!empty_nodes) summary(df.cluster01)
if (!empty_nodes) summary(df.cluster02)
if (!empty_nodes) summary(df.cluster03)
if (!empty_nodes) summary(df.cluster04)
if (!empty_nodes) summary(df.cluster05)
if (!empty_nodes) {
df.clusters.dim <- c(dim(df.cluster01)[1], dim(df.cluster02)[1], dim(df.cluster03)[1], dim(df.cluster04)[1], dim(df.cluster05)[1])
barplot(df.clusters.dim,
names.arg = c("cluster01", "cluster02", "cluster03", "cluster04", "cluster05"),
col = "steelblue1")
}
if (!empty_nodes) mpr.hist(df.cluster01)
if (!empty_nodes) mpr.hist(df.cluster02)
if (!empty_nodes) mpr.hist(df.cluster03)
if (!empty_nodes) mpr.hist(df.cluster04)
if (!empty_nodes) mpr.hist(df.cluster05)
if (!empty_nodes) mpr.boxplot(df.cluster01)
if (!empty_nodes) mpr.boxplot(df.cluster02)
if (!empty_nodes) mpr.boxplot(df.cluster03)
if (!empty_nodes) mpr.boxplot(df.cluster04)
if (!empty_nodes) mpr.boxplot(df.cluster05)
# Agrupa por longitud y latitud para rellenar el mapa con menos datos.
if (!empty_nodes) {
df.cluster01.grouped <- mpr.group_by_geo(df.cluster01)
df.cluster02.grouped <- mpr.group_by_geo(df.cluster02)
df.cluster03.grouped <- mpr.group_by_geo(df.cluster03)
df.cluster04.grouped <- mpr.group_by_geo(df.cluster04)
df.cluster05.grouped <- mpr.group_by_geo(df.cluster05)
}
if (!empty_nodes) mpr.draw_map(spain, df.cluster01.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster02.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster03.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster04.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster05.grouped)
if (!empty_nodes) {
plot(hac, hang=-1, labels=F)
rect.hclust(hac, k=6)
}
A qué clúster pertenece cada nodo del mapa de kohonen:
if (!empty_nodes) {
groups <- cutree(hac, k=6)
plot(model, type="mapping",
bgcol=c("steelblue1","sienna1","yellowgreen","red","blue","yellow","purple","green","white","#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')[groups],
shape = "straight", labels = "")
add.cluster.boundaries(model, clustering=groups)
}
if (!empty_nodes) {
# Asignamos a cada registro su clúster
df$cluster <- groups[model$unit.classif]
}
Nuevos dataframes por cluster
if (!empty_nodes) {
# Creo nuevos dataframes, uno por cada clúster.
df.cluster01 <- subset(df, cluster==1)
df.cluster02 <- subset(df, cluster==2)
df.cluster03 <- subset(df, cluster==3)
df.cluster04 <- subset(df, cluster==4)
df.cluster05 <- subset(df, cluster==5)
df.cluster06 <- subset(df, cluster==6)
# Extraigo del dataframe las features.
df.cluster01 <- select(df.cluster01, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster02 <- select(df.cluster02, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster03 <- select(df.cluster03, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster04 <- select(df.cluster04, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster05 <- select(df.cluster05, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster06 <- select(df.cluster06, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
}
if (!empty_nodes) summary(df.cluster01)
if (!empty_nodes) summary(df.cluster02)
if (!empty_nodes) summary(df.cluster03)
if (!empty_nodes) summary(df.cluster04)
if (!empty_nodes) summary(df.cluster05)
if (!empty_nodes) summary(df.cluster06)
if (!empty_nodes) {
df.clusters.dim <- c(dim(df.cluster01)[1], dim(df.cluster02)[1], dim(df.cluster03)[1], dim(df.cluster04)[1], dim(df.cluster05)[1], dim(df.cluster06)[1])
barplot(df.clusters.dim,
names.arg = c("cluster01", "cluster02", "cluster03", "cluster04", "cluster05", "cluster06"),
col = "steelblue1")
}
if (!empty_nodes) mpr.hist(df.cluster01)
if (!empty_nodes) mpr.hist(df.cluster02)
if (!empty_nodes) mpr.hist(df.cluster03)
if (!empty_nodes) mpr.hist(df.cluster04)
if (!empty_nodes) mpr.hist(df.cluster05)
if (!empty_nodes) mpr.hist(df.cluster06)
if (!empty_nodes) mpr.boxplot(df.cluster01)
if (!empty_nodes) mpr.boxplot(df.cluster02)
if (!empty_nodes) mpr.boxplot(df.cluster03)
if (!empty_nodes) mpr.boxplot(df.cluster04)
if (!empty_nodes) mpr.boxplot(df.cluster05)
if (!empty_nodes) mpr.boxplot(df.cluster06)
# Agrupa por longitud y latitud para rellenar el mapa con menos datos.
if (!empty_nodes) {
df.cluster01.grouped <- mpr.group_by_geo(df.cluster01)
df.cluster02.grouped <- mpr.group_by_geo(df.cluster02)
df.cluster03.grouped <- mpr.group_by_geo(df.cluster03)
df.cluster04.grouped <- mpr.group_by_geo(df.cluster04)
df.cluster05.grouped <- mpr.group_by_geo(df.cluster05)
df.cluster06.grouped <- mpr.group_by_geo(df.cluster06)
}
if (!empty_nodes) mpr.draw_map(spain, df.cluster01.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster02.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster03.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster04.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster05.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster06.grouped)
if (!empty_nodes) {
plot(hac, hang=-1, labels=F)
rect.hclust(hac, k=8)
}
A qué clúster pertenece cada nodo del mapa de kohonen:
if (!empty_nodes) {
groups <- cutree(hac, k=8)
plot(model, type="mapping",
bgcol=c("steelblue1","sienna1","yellowgreen","red","blue","yellow","purple","green","white","#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')[groups],
shape = "straight", labels = "")
add.cluster.boundaries(model, clustering=groups)
}
if (!empty_nodes) {
# Asignamos a cada registro su clúster
df$cluster <- groups[model$unit.classif]
}
Nuevos dataframes por cluster
if (!empty_nodes) {
# Creo nuevos dataframes, uno por cada clúster.
df.cluster01 <- subset(df, cluster==1)
df.cluster02 <- subset(df, cluster==2)
df.cluster03 <- subset(df, cluster==3)
df.cluster04 <- subset(df, cluster==4)
df.cluster05 <- subset(df, cluster==5)
df.cluster06 <- subset(df, cluster==6)
df.cluster07 <- subset(df, cluster==7)
df.cluster08 <- subset(df, cluster==8)
# Extraigo del dataframe las features.
df.cluster01 <- select(df.cluster01, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster02 <- select(df.cluster02, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster03 <- select(df.cluster03, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster04 <- select(df.cluster04, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster05 <- select(df.cluster05, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster06 <- select(df.cluster06, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster07 <- select(df.cluster07, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster08 <- select(df.cluster08, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
}
if (!empty_nodes) summary(df.cluster01)
if (!empty_nodes) summary(df.cluster02)
if (!empty_nodes) summary(df.cluster03)
if (!empty_nodes) summary(df.cluster04)
if (!empty_nodes) summary(df.cluster05)
if (!empty_nodes) summary(df.cluster06)
if (!empty_nodes) summary(df.cluster07)
if (!empty_nodes) summary(df.cluster08)
if (!empty_nodes) {
df.clusters.dim <- c(dim(df.cluster01)[1], dim(df.cluster02)[1], dim(df.cluster03)[1], dim(df.cluster04)[1], dim(df.cluster05)[1], dim(df.cluster06)[1], dim(df.cluster07)[1], dim(df.cluster08)[1])
barplot(df.clusters.dim,
names.arg = c("cluster01", "cluster02", "cluster03", "cluster04", "cluster05", "cluster06", "cluster07", "cluster08"),
col = "steelblue1")
}
if (!empty_nodes) mpr.hist(df.cluster01)
if (!empty_nodes) mpr.hist(df.cluster02)
if (!empty_nodes) mpr.hist(df.cluster03)
if (!empty_nodes) mpr.hist(df.cluster04)
if (!empty_nodes) mpr.hist(df.cluster05)
if (!empty_nodes) mpr.hist(df.cluster06)
if (!empty_nodes) mpr.hist(df.cluster07)
if (!empty_nodes) mpr.hist(df.cluster08)
if (!empty_nodes) mpr.boxplot(df.cluster01)
if (!empty_nodes) mpr.boxplot(df.cluster02)
if (!empty_nodes) mpr.boxplot(df.cluster03)
if (!empty_nodes) mpr.boxplot(df.cluster04)
if (!empty_nodes) mpr.boxplot(df.cluster05)
if (!empty_nodes) mpr.boxplot(df.cluster06)
if (!empty_nodes) mpr.boxplot(df.cluster07)
if (!empty_nodes) mpr.boxplot(df.cluster08)
# Agrupa por longitud y latitud para rellenar el mapa con menos datos.
if (!empty_nodes) {
df.cluster01.grouped <- mpr.group_by_geo(df.cluster01)
df.cluster02.grouped <- mpr.group_by_geo(df.cluster02)
df.cluster03.grouped <- mpr.group_by_geo(df.cluster03)
df.cluster04.grouped <- mpr.group_by_geo(df.cluster04)
df.cluster05.grouped <- mpr.group_by_geo(df.cluster05)
df.cluster06.grouped <- mpr.group_by_geo(df.cluster06)
df.cluster07.grouped <- mpr.group_by_geo(df.cluster07)
df.cluster08.grouped <- mpr.group_by_geo(df.cluster08)
}
if (!empty_nodes) mpr.draw_map(spain, df.cluster01.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster02.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster03.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster04.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster05.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster06.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster07.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster08.grouped)
if (!empty_nodes) {
plot(hac, hang=-1, labels=F)
rect.hclust(hac, k=10)
}
A qué clúster pertenece cada nodo del mapa de kohonen:
if (!empty_nodes) {
groups <- cutree(hac, k=10)
plot(model, type="mapping",
bgcol=c("steelblue1","sienna1","yellowgreen","red","blue","yellow","purple","green","white","#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')[groups],
shape = "straight", labels = "")
add.cluster.boundaries(model, clustering=groups)
}
if (!empty_nodes) {
# Asignamos a cada registro su clúster
df$cluster <- groups[model$unit.classif]
}
Nuevos dataframes por cluster
if (!empty_nodes) {
# Creo nuevos dataframes, uno por cada clúster.
df.cluster01 <- subset(df, cluster==1)
df.cluster02 <- subset(df, cluster==2)
df.cluster03 <- subset(df, cluster==3)
df.cluster04 <- subset(df, cluster==4)
df.cluster05 <- subset(df, cluster==5)
df.cluster06 <- subset(df, cluster==6)
df.cluster07 <- subset(df, cluster==7)
df.cluster08 <- subset(df, cluster==8)
df.cluster09 <- subset(df, cluster==9)
df.cluster10 <- subset(df, cluster==10)
# Extraigo del dataframe las features.
df.cluster01 <- select(df.cluster01, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster02 <- select(df.cluster02, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster03 <- select(df.cluster03, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster04 <- select(df.cluster04, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster05 <- select(df.cluster05, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster06 <- select(df.cluster06, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster07 <- select(df.cluster07, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster08 <- select(df.cluster08, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster09 <- select(df.cluster09, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
df.cluster10 <- select(df.cluster10, fecha_cnt, tmax, tmin, precip, nevada, prof_nieve, longitud, latitud, altitud)
}
if (!empty_nodes) summary(df.cluster01)
if (!empty_nodes) summary(df.cluster02)
if (!empty_nodes) summary(df.cluster03)
if (!empty_nodes) summary(df.cluster04)
if (!empty_nodes) summary(df.cluster05)
if (!empty_nodes) summary(df.cluster06)
if (!empty_nodes) summary(df.cluster07)
if (!empty_nodes) summary(df.cluster08)
if (!empty_nodes) summary(df.cluster09)
if (!empty_nodes) summary(df.cluster10)
if (!empty_nodes) {
df.clusters.dim <- c(dim(df.cluster01)[1], dim(df.cluster02)[1], dim(df.cluster03)[1], dim(df.cluster04)[1], dim(df.cluster05)[1], dim(df.cluster06)[1], dim(df.cluster07)[1], dim(df.cluster08)[1], dim(df.cluster09)[1], dim(df.cluster10)[1])
barplot(df.clusters.dim,
names.arg = c("cluster01", "cluster02", "cluster03", "cluster04", "cluster05", "cluster06", "cluster07", "cluster08", "cluster09", "cluster10"),
col = "steelblue1")
}
if (!empty_nodes) mpr.hist(df.cluster01)
if (!empty_nodes) mpr.hist(df.cluster02)
if (!empty_nodes) mpr.hist(df.cluster03)
if (!empty_nodes) mpr.hist(df.cluster04)
if (!empty_nodes) mpr.hist(df.cluster05)
if (!empty_nodes) mpr.hist(df.cluster06)
if (!empty_nodes) mpr.hist(df.cluster07)
if (!empty_nodes) mpr.hist(df.cluster08)
if (!empty_nodes) mpr.hist(df.cluster09)
if (!empty_nodes) mpr.hist(df.cluster10)
if (!empty_nodes) mpr.boxplot(df.cluster01)
if (!empty_nodes) mpr.boxplot(df.cluster02)
if (!empty_nodes) mpr.boxplot(df.cluster03)
if (!empty_nodes) mpr.boxplot(df.cluster04)
if (!empty_nodes) mpr.boxplot(df.cluster05)
if (!empty_nodes) mpr.boxplot(df.cluster06)
if (!empty_nodes) mpr.boxplot(df.cluster07)
if (!empty_nodes) mpr.boxplot(df.cluster08)
if (!empty_nodes) mpr.boxplot(df.cluster09)
if (!empty_nodes) mpr.boxplot(df.cluster10)
# Agrupa por longitud y latitud para rellenar el mapa con menos datos.
if (!empty_nodes) {
df.cluster01.grouped <- mpr.group_by_geo(df.cluster01)
df.cluster02.grouped <- mpr.group_by_geo(df.cluster02)
df.cluster03.grouped <- mpr.group_by_geo(df.cluster03)
df.cluster04.grouped <- mpr.group_by_geo(df.cluster04)
df.cluster05.grouped <- mpr.group_by_geo(df.cluster05)
df.cluster06.grouped <- mpr.group_by_geo(df.cluster06)
df.cluster07.grouped <- mpr.group_by_geo(df.cluster07)
df.cluster08.grouped <- mpr.group_by_geo(df.cluster08)
df.cluster09.grouped <- mpr.group_by_geo(df.cluster09)
df.cluster10.grouped <- mpr.group_by_geo(df.cluster10)
}
if (!empty_nodes) mpr.draw_map(spain, df.cluster01.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster02.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster03.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster04.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster05.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster06.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster07.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster08.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster09.grouped)
if (!empty_nodes) mpr.draw_map(spain, df.cluster10.grouped)